1. Field of the Invention
The present invention relates to a PLC (Programmable Logic Controller) having a power failure compensation function and a power failure compensation method, and in particular to an improved PLC having a power failure compensation function and a power failure compensation method which are capable of implementing the continuity of a program operation when a power failure occurs.
2. Description of the Background Art
The PLC (Programmable Logic controller) is an apparatus for controlling electrical switches (input and output contact points) such as a manufacturing automation system, etc. which is connected with the PLC based on the program which is set by a user.
The PLC system adapts a LAN (Local Area Network), which is capable of communicating data in real time, and a multi-drop (1:N communication) in which multiple communication stations are connected with one network.
Therefore, in the factory automation system, the PLCs which are installed in each line receives/transmits the data of each line such as the number of packages, the number of errors, the number of output products, etc. from/to the PLC, so that the system is operated in accordance with the data received.
As shown in FIG. 1, the conventional PLC includes an electric power unit 10 for supplying an electric power to elements of the system, a CPU (Central Processing Unit) 11 which operates in accordance with the program set by a user, an input unit 12 for providing the data processed by a control target 14, which is controlled, and an output unit 13 for outputting a control signal from the CPU 11 to the control target 14.
The operation of the conventional PLC will now be explained with reference to the accompanying drawings.
The electric power unit 10 converts an AC input power into a DC power and supplies to the CPU 11 and the input and output units 12 and 13, and the CPU 11 reads a state of the control target 14 through the input unit 12, performs the program made by a user, and outputs through the output unit 13. The PLC controls the control target 14 in the above-described method.
In addition, the PLC repeatedly performs the program made by the user, and updates a result thereof into a data memory of the PLC. The data memory stores the content of the memory by a battery during a power failure. Therefore, in the PLC operation mode, the user determines whether the data value is stored in the memory data in accordance with the characteristic of the control target 14 which is to be controlled for operating the PLC.
While the user sets the mode for storing the data value and operates the PLC, if a power failure occurs and then the execution of the program is stopped due to the power failure, the data which is initially set to be stored may be different with the data which is obtained by normally executing the program.
As a result of the operation, a different operation result may be produced in accordance with the position where the program is stopped due to the power failure. In addition, when re-operating the PLC, since the CPU 11 re-executes the program from the first step of the user's program using the operation result which is obtained until the program is stopped, the continuity of the program execution is not obtained before and after the power failure.
FIG. 2 illustrates the user's program which is executed by the PLC.
The user's program consists of Step 1 through Step 12. Namely, the program is designed to add 1, 2 and 3 to the contact points B, C and D, respectively, when the contact point A is turned on. At this time, A denotes a bool value, and B, C and D are integer values and are set to be stored.
First, the user's program is normally performed from Step 1 to Step 12, the integer values B, C and D become 5, 10 and 15, respectively, and the next expressions of C=2*B, D=3*D are obtained based on the above-described values.
If the user's program is normally performed from Step 1 to Step 12 four times, and then a power failure occurs just before performing Step 8 during the fifth operation, the operation values 5, 8 and 12 which are obtained until Step 7 are stored into the data memory as the integer values of 5, 8 and 12.
If the power failure is recovered, the CPU 11 reads the values of B, C and D stored in the data memory, and the program is performed from Step 1 without performing the program from the step stopped due to the power failure. Therefore, the integer values of B, C and D which are obtained after the program is performed five times become 6, 10 and 15, respectively, and the operation values do not satisfy the equation of C+2*B, D=3*B, so that the operation of the PLC may be erroneously performed.
Namely, in the conventional PLC, since the continuity of the user's program is not maintained before/after the power failure, there may occur a malfunction of the PLC.